package com.gin

import com.gin.danbooru.main.Danbooru
import com.gin.danbooru.response.detail.PostsDetail
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

/**
 * @author BX-Gin
 * @from 2024/2/27 9:57
 */
fun main() {
    val client = Danbooru.obtainOkHttpClient()
    val retrofit = Danbooru.obtainRetrofit(client)
    val danbooru = Danbooru(retrofit)

//    val tags = "pixiv:99147997"
//    val tags = "animated"
//    val tags = "girls_frontline"
//    danbooru.postsApi().getSearch(tags).enqueue(object : Callback<PostsSearchBody?> {
//        override fun onResponse(p0: Call<PostsSearchBody?>, p1: Response<PostsSearchBody?>) {
//            println(Danbooru.MAPPER.writeValueAsString(p1.body()))
//        }
//
//        override fun onFailure(p0: Call<PostsSearchBody?>, p1: Throwable) {
//            p1.printStackTrace()
//        }
//    })

    danbooru.postsApi().getDetail(5442516).enqueue(object : Callback<PostsDetail?> {
        override fun onResponse(p0: Call<PostsDetail?>, p1: Response<PostsDetail?>) {
            println(Danbooru.MAPPER.writeValueAsString(p1.body()))
        }

        override fun onFailure(p0: Call<PostsDetail?>, p1: Throwable) {
            TODO("Not yet implemented")
        }
    })

}